<?php

namespace App\Http\Controllers;

use App\Common\ApiErrorCode;
use App\Common\JwtAuth;
use App\Exceptions\ApiException;
use Illuminate\Http\Request;

class JwtLoginController extends Controller
{
    public function login()
    {

//        $arr = [];
//        if ($arr == null){
//            abort('404');
//            exit();
//        }
        //获取客户端传递的参数

        //去数据库或缓存中验证该用户

        //获取jwt token字符串（模拟客户端）
        $jwtAuth = JwtAuth::getInstance();
        $token = $jwtAuth->setUid(1)->encode()->getToken();
        // 获取到客户端提交 token
        return $token;
    }

    public function token()
    {
        $jwtAuth = JwtAuth::getInstance();
        return $jwtAuth->setUid(1)->encode()->getToken();
    }

}
